package com.example.jooqdemo.controller;

import com.example.jooqdemo.dao.UserDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: java类作用描述
 * @Author: czw
 * @date: 2018/4/27
 */
@RestController
public class TestContrller {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private UserDao userDao;

    @RequestMapping("/test")
    public String test() {
        System.out.println("开始测试。。。。");
        int execute = userDao.saveUser();
        System.out.println("execute ======> " + execute);
        // int i = 1 / 0;
        return "返回执行结果：" + execute;
    }

    @RequestMapping("/getUser")
    public String getUser() {
        logger.info("开始测试。。。。");
        userDao.getUser();
        return "返回执行结果：";
    }

    @RequestMapping("/getNub")
    public String getNub() {
        System.out.println("开始测试。。。。");

        return "返回执行结果：" + userDao.getNub();
    }


    @RequestMapping("/addUser")
    public String addUser() {
        logger.info("开始测试。。。。");
        System.out.println("开始测试。。。。");
        // userDao.addUser();
        userDao.insertUser();
        return "测试AOP事务：";
    }
}
